package org.lboot.rbac.util;

import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.DesensitizedUtil;
import org.lboot.rbac.module.user.SysUser;

/**
 * @author kindear
 * RBAC 工具类
 */
public class RbacUtil {
    /**
     * 隐私信息加密操作
     * @param user
     * @return
     */
    public static SysUser desensitize(SysUser user){
        user.setPassword(DesensitizedUtil.password(user.getPassword()));
        if (Validator.isNotEmpty(user.getMobile())){
            user.setMobile(DesensitizedUtil.mobilePhone(user.getMobile()));
        }
        if (Validator.isNotEmpty(user.getCardId())){
            user.setCardId(DesensitizedUtil.idCardNum(user.getCardId(),1,2));
        }
        return user;
    }
}
